  <% dates.each do |d| %>
    <div class="date-item">
	  <p>
	    <% if !events.nil? %>
	      <strong><%=h d.event %> : </strong>
		<% end %>
	    <%=h d.date_string_with_month %>
		
		<% if item.class.to_s == 'Edition' && !d.country.blank? %>
		  in <%=h d.country %>
		<% end %>
		
		<%= link_to_function "&nbsp; Edit", "$('edit-date-item-#{d.id}').show(), this.up(1).hide()" %> |
		<%= link_to_remote 'x', :url => d, :method => :delete %>
      </p>
    </div>
	
	<div id="edit-date-item-<%=h d.id %>" style="display: none">
	  <% form_remote_for :edit_date, :url => d, :method => :put do |f| %>
	    <%= f.hidden_field :id, :value => item.id %>
	    <%= f.select :month, FullDate::MONTH_ARRAY, :selected => d.month %>
	    <%= f.select :day, (1..31).to_a, :include_blank => true, :selected => d.day %>
	    <%= f.text_field :year, :size => 1, :value => d.year %>
		
		<% if item.class.to_s == 'Edition' %>
		  <%= f.text_field :country_name, :value => d.country %>
		<% end %>
		
        <%= f.submit "Save Changes" %>
		<%= submit_tag 'Cancel', :type => 'button', :onclick => "this.up(1).hide(),this.up(1).previous('.date-item').show(),this.form.reset()" %>
	  <% end %>
	</div>
  <% end %>
  
  <div id="date-form-<%=h item.class %>" style="display: none">
    <% form_remote_for :new_date, :url => dates_url do |f| %>
      <%= f.hidden_field :id, :value => item.id %>
	  
	  <% if !events.nil? %>
        <%= f.select :event, events %>
	  <% end %>
	  
	  <%= f.select :month, FullDate::MONTH_ARRAY %>
	  <%= f.select :day, (1..31).to_a, :include_blank => true %>
	  <%= f.text_field :year, :size => 1 %>
	  
	  <% if item.class.to_s == 'Edition' %>
	    <%= f.text_field :country_name %>
	   <% end %>
		
      <%= f.submit "Add Date" %>
	  <%= submit_tag 'Cancel', :type => 'button', :onclick => "this.up(1).hide(),this.up(1).next('p').show(),this.form.reset()" %>
    <% end %>
  </div>
  
  <p><%= link_to_function "New Date", "$('date-form-#{item.class}').show(), this.up().hide()" %></p>